<template>
  <div class="sex">
    <div class="sex_top">
      <p class="sex_title">男女比例</p>
      <p class="sex_bg"></p>
    </div>
    <div class="sex_two">
      <div class="man">
        <img src="../../../images/man.png" alt="">
      </div>
      <div class="women">
        <img src="../../../images/woman.png" alt="">
      </div>
    </div>
    <div class="rate">
      <p>男士58%</p>
      <p>女性42%</p>
    </div>
    <div class="charts" ref="charts"></div>
  </div>
</template>

<script setup lang='ts'>
import * as echarts from 'echarts'
import { onMounted, ref } from 'vue'

// 获取图形的dom节点
let charts = ref()
onMounted(() => {
  // 初始化echarts实例
  let mycharts = echarts.init(charts.value)
  // 设置配置项
  mycharts.setOption({
    // 主题
    title: {
      text: '男女比例',//主题标题
      textStyle: {
        color: 'skybule'//主题字体颜色
      },
      left: '50%'
    },
    xAxis: {
      show: false,
      min: 0,
      max: 100,
    },
    yAxis: {
      show: false,
      type: 'category',
    },
    series: [
      {
        type: 'bar',
        data: [60],
        barWidth: 20,
        z: 3,
        itemStyle: {
        color:'skyblue',
        borderRadius: 20,
        },
      },
      {
        type: 'bar',
        data: [100],
        barWidth: 20,
        // 调整女士柱形图位置
        barGap: '-100%',
        itemStyle: {
          color: 'pink',
          borderRadius: 20,
        },
        
      },
    ],
    gtid: {
      left: 0,
      top: 0,
      right: 0,
      bottom: 0,
    }
  });
})
</script>

<style scoped>
.sex {
  margin-top: 20px;
  background: url(../../../images/dataScreen-main-lb.png) no-repeat;
  background-size: 100% 100%;

  .sex_top {
    margin-left: 20px;

    .sex_title {
      color: white;
      font-size: 20px;
    }

    .sex_bg {
      margin-top: 10px;
      width: 68px;
      height: 7px;
      background: url(../../../images/dataScreen-title.png) no-repeat;
      background-size: 100% 100%;
    }
  }

  .sex_two {
    display: flex;
    justify-content: center;

    .man {
      display: flex;
      justify-content: center;
      align-items: center;
      margin: 25px;
      width: 111px;
      height: 115px;
      background: url(../../../images/man-bg.png) no-repeat;
    }

    .women {
      display: flex;
      justify-content: center;
      align-items: center;
      margin: 25px;
      width: 111px;
      height: 115px;
      background: url(../../../images/woman-bg.png) no-repeat;
    }
  }

  .rate {
    display: flex;
    justify-content: space-around;
    color: white;
  }
  

  .charts {
    height: 100px;

  }
}
</style>